﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.LightSwitch;
namespace LightSwitchApplication
{
    public partial class FishFeed
    {
        partial void TotalRaiting_Compute(ref double result)
        {
            if (FishFeedComments.Count() == 0)
            {
                result = 3;
                return;
            }
            result = (double)FishFeedComments.Sum(item => item.Rating) / (double)FishFeedComments.Count();

        }

        partial void Name_Compute(ref string result)
        {
            result = string.Format("{0} / \"{1}\"", Fish.Name, Feed.Name);

        }

        partial void CommentCount_Compute(ref int result)
        {
            result = FishFeedComments.Count();

        }
    }
}
